<template>
  <div class="userList">
    <header>用户管理</header>
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="id" label="ID" width="180"></el-table-column>
      <el-table-column prop="username" label="用户名" width="180"></el-table-column>
      <el-table-column prop="email" label="邮箱"></el-table-column>
      <el-table-column prop="phone" label="电话"></el-table-column>
      <el-table-column prop="createTime" label="注册时间"></el-table-column>
    </el-table>
    <!-- <div class="block"> -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page.sync="currentPage"
      :page-size="pageSize"
      layout="prev, pager, next, jumper"
      :total="total"
      background
      class="pagination"
    ></el-pagination>
    <!-- </div> -->
  </div>
</template>

<script>
import { userList } from "../../util/netWork";
export default {
  data() {
    return {
      tableData: [],
      currentPage: 1,
      pageSize: 10,
      pageNum: 1,
      total: 0
    };
  },
  methods: {
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      //   console.log(`当前页: ${val}`);
      this.pageNum = val;
      this.http();
    },
    http() {
      let data = {
        pageSize: this.pageSize,
        pageNum: this.pageNum
      };
      userList(data).then(res => {
        if (res.status == 0) {
          //   console.log(res.data);
          this.tableData = res.data.list;
          this.total = res.data.total;
          this.pagesize = res.data.pagesize;
        }
      });
    }
  },
  mounted() {
    this.http();
  }
};
</script>

<style lang="scss" scoped>
@import "@/assets/mixinScss.scss";
header {
  @include FontSize(30px);
  @include Size(100%, 100px);
  line-height: 100px;
  box-sizing: border-box;
  padding-left: 20px;
}
.pagination {
  @include Size(100%, 50px);
  text-align: center;
  @include Margin(20px, 0);
}
</style>